package com.qlzb.taskmanagement.persistentData.entity;

import com.qlzb.taskmanagement.utils.CommonUtil;
import com.qlzb.taskmanagement.utils.ParseAnnotation;
import com.qlzb.taskmanagement.vo.quartzVo.OperationColumnId;
import org.apache.commons.beanutils.PropertyUtils;
import org.jsoup.nodes.Element;

import java.lang.reflect.Field;

/**
 * 运维系统的Fsu监控
 */
public class Fsu {
    //名称
    @OperationColumnId(name ="名称",j_id = 134)
    String name;
    //运维id
    @OperationColumnId(name ="FSU运维ID",j_id = 139)
    String operationId;
    //站址运维ID
    @OperationColumnId(name ="站址运维ID",j_id = 124)
    String stationOperid;
    //站址编码
    @OperationColumnId(name ="站址编码",j_id = 129)
    String stationCode;
    //站址名称
    @OperationColumnId(name ="站址",j_id = 119)
    String stationName;
    //状态
    @OperationColumnId(name ="FSU状态",j_id = 247)
    String fsuStatus;
    //代维公司
    @OperationColumnId(name ="代维公司",j_id = 144)
    String company;
    //离线时间
    @OperationColumnId(name ="代维公司",j_id = 216)
    String alarmDate;

    //将数据封装成指定对象
    public Fsu(Element row){
        Field[] fields= CommonUtil.getFields(this.getClass());
        Element indexTd = row.select("td").get(1).select("center").first();
        int i = Integer.parseInt(indexTd.text());
        i = i - 1;
        for(Field field:fields){
            String filedName=field.getName();
            int j_id= ParseAnnotation.getOperationColumnId(field);
            Element stationLink = row.select("[id=queryForm:list:"+i+":j_id"+j_id+"]").first();
            String filedValue= stationLink.text();
            try {
                if(filedName.equals("fsuStatus")){
                    if (filedValue.equals("交维")) filedValue = "3";
                    if (filedValue.equals("检修")) filedValue = "6";
                }
                PropertyUtils.setProperty(this,filedName,filedValue);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public String getAlarmDate() {
        return alarmDate;
    }

    public void setAlarmDate(String alarmDate) {
        this.alarmDate = alarmDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOperationId() {
        return operationId;
    }

    public void setOperationId(String operationId) {
        this.operationId = operationId;
    }

    public String getStationName() {
        return stationName;
    }

    public void setStationName(String stationName) {
        this.stationName = stationName;
    }

    public String getStationOperid() {
        return stationOperid;
    }

    public void setStationOperid(String stationOperid) {
        this.stationOperid = stationOperid;
    }

    public String getStationCode() {
        return stationCode;
    }

    public void setStationCode(String stationCode) {
        this.stationCode = stationCode;
    }


    public String getFsuStatus() {
        return fsuStatus;
    }

    public void setFsuStatus(String fsuStatus) {
        this.fsuStatus = fsuStatus;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

}
